﻿using BLL;
using Model;
using DAL;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tools;
using System.IO.Ports;
using System.IO;

namespace 校准综测
{
    public class JZZCFormBLL
    {
        private SimbaBLL simbaBLL = new SimbaBLL();
        private ML302DAL mL302DAL = new ML302DAL();
        public string GetReslut(string logFolder, string snimei,string station,string box, PortBLL portBLL, SerialPort port,AppHelper app,bool firstTime, string devcode)
        {
            string result = PortModel.NGResult;
            var t1 = Task.Factory.StartNew(() => result = simbaBLL.IsPass(logFolder, snimei,station,box,portBLL,port,app, firstTime, devcode));
            Task.WaitAll(t1);
            return result;
        }
        //public static bool firstFail = false;
        public string Upload(string snimei, string result, string devcode,Label label)
        {
            SysTestModel testModel = simbaBLL.GetTestModel(snimei, result, devcode);
            //if (testModel.param1!=null && firstFail == false)
            //{
            //    if ((testModel.param1.Contains("EnterMode") || testModel.param1.Contains("User_Stop")) )
            //    {
            //        firstFail = true;
            //        return "firstFail";
            //    }
            //}
            if (testModel==null)
            {
                return "NG";
            }
            mL302DAL. WriteSynTest(label, testModel);
            //firstFail = false;
            return "OK";
        }
        //public void Move()
        //{
        //    simbaBLL.MoveLog();
        //}
    }
}